package com.czk.webflux.reactor8;

import java.util.Observable;

/**
 * @Author:ChenZhangKun
 * @Date: 2020/11/25 21:44
 */
public class ObserverDemo extends Observable {
    public static void main(String[] args) {
        ObserverDemo observerDemo=new ObserverDemo();
        // 添加观察者
        observerDemo.addObserver((o,arg)->{
            System.out.println("发生变化");
        });
        observerDemo.addObserver((o,arg)->{
            System.out.println("手动被观察者通知，准备改变");
        });
        // 知道数据变化
        observerDemo.setChanged();
        // 进行通知
        observerDemo.notifyObservers();
    }
}
